// 审批结果页面
<template>
  <div class="app-container">
    <el-card class="box-card" shadow="never" style="border:0px;">
      <div slot="header" style="font-size:14px;font-weight:bold;">
        <span>审批结果</span>
      </div>
    <div class="filter-container" id="searchBox">
      <div class="left">
        <el-form :inline="true" class="demo-form-inline" size="medium" label-position="right">
          <el-form-item label="姓名：">
            <el-input v-model="listQuery.realName" clearable class="filter-item" placeholder="请输入借款人姓名" />
          </el-form-item>
          <el-form-item label="手机号：">
            <el-input v-model="listQuery.mobile" clearable class="filter-item" placeholder="请输入借款人手机号" />
          </el-form-item>
          <el-form-item label="身份证号：">
            <el-input v-model="listQuery.idCardNo" clearable class="filter-item" placeholder="请输入借款人身份证号" />
          </el-form-item>
          <!-- <el-form-item label="任务流程：">
            <DicSelect dictType="项目状态" :dictValue="listQuery.projectStatus" v-on:dictValue="listQuery.projectStatus = $event" />
          </el-form-item> -->
          <el-form-item label="抵押类型：">
            <DicSelect dictType="抵押类型" :dictValue="listQuery.pledgeType" v-on:dictValue="listQuery.pledgeType = $event" />
          </el-form-item>
          <el-form-item label="开始时间：">
            <el-date-picker
              class="date_item"
              v-model="listQuery.submitStartDate"
              type="datetime"
              placeholder="选择开始时间"
              align="right"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="结束时间：">
            <el-date-picker
              class="date_item"
              v-model="listQuery.submitEndDate"
              type="datetime"
              placeholder="选择结束时间"
              align="right"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </el-form-item>
        </el-form>
      </div>
      <div class="right">
        <el-button type="primary"  @click="getList(listQuery)">查询</el-button>
        <el-button @click="restForm">重置</el-button>
        <el-button  type="text" @click="closeSearch">{{showOperation}}<i :class="[!showAll? 'el-icon-caret-bottom' : 'el-icon-caret-top']"></i>
               </el-button>
      </div>
    </div>
<vxe-toolbar ref="xToolbar">
         <template #buttons>
        </template>
    </vxe-toolbar>
    <vxe-table
      v-loading="listLoading"
      :data="taskData"
      border="none"
      highlight-hover-row
      show-header-overflow
      show-overflow
      align="center"
      :header-cell-style="{ background: '#F7F7F8', color: '#606266' }"
      @cell-dblclick="cellDblclick"
    >
      <vxe-table-column type="seq" title="序号" width="60"/>
      <vxe-table-column title="客户姓名" field="realName" />
      <vxe-table-column title="身份证号" field="idCardNo" />
      <vxe-table-column title="手机号" field="mobile" />
      <vxe-table-column title="抵押类型" field="pledgeTypeName" />
      <vxe-table-column title="借贷金额(万)" field="applyAmount" />
      <vxe-table-column title="借贷期限" field="applyTermName" />
      <vxe-table-column title="创建时间" field="createTime" />
      <vxe-table-column title="状态" field="projectStatusName" />
      <vxe-table-column fixed="right" width="150" title="操作">
        <template v-slot="{ row }">
          <!-- <el-button type="success" size="small" round @click="receiveTask(row)" v-if="row.taskStatus === 1">立即处理</el-button>
          <el-button type="primary" size="small" round @click="getTask(row)" v-else>查看</el-button> -->
          <el-button type="text" @click="getTask(row)" v-if="row.ifReceive === 0">查看</el-button>
          <el-button type="text"  @click="receiveTask(row)" v-else>立即处理</el-button>
        </template>
      </vxe-table-column>
    </vxe-table>
    </el-card>
    <vxe-pager
      class="pager"
      @page-change="changePage"
      :current-page.sync="listQuery.pageNo"
      :page-size.sync="listQuery.pageSize"
      :total="total"
      :page-sizes="[10, 30, 50, 100]"
      :layouts="['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
    >
    </vxe-pager>
  </div>
</template>

<script>
import { listTasks,receiveTask} from '@/api/project';
import DicSelect from '@/components/select/index';
export default {
  name: 'User',
  components: { DicSelect },
  data: function () {
    return {
      active: 0,
      taskData: [],
      total: 0,
      listLoading: true,
      listQuery: {
        pageNo: 1,
        pageSize: 10,
        realName: undefined,
        mobile: undefined,
        idCardNo: undefined,
        pledgeType: undefined,
        projectStatus: undefined,
        startTime: undefined,
        endTime: undefined,
      },
      showAll:true,
    };
  },
  computed: {
    showOperation: function() {
   if (this.showAll == false) {
    //对文字进行处理
    return "展开";
   } else {
    return "收起";
   }
  }
  },
  mounted(){
  /**
   * 收起搜索
   */
  this.$nextTick(function() {
  //  this.closeSearch();
  });
  },
 created () {
    this.getList();
  },
  // getTask
  methods: {
    // 列表查询
    getList() {
      this.listLoading = true;
      this.listQuery.projectStatus = 23;//项目状态 23：待确认
      listTasks(this.listQuery).then((data) => {
        this.taskData = data.data;
        this.total = data.total;
        console.log('响应数据:%o', data);
        this.listLoading = false;
      });
    },
    closeSearch() {
   this.showAll = !this.showAll;
   var searchBoxHeght = document.getElementById("searchBox");
   if (this.showAll == false) {
    searchBoxHeght.style.height = 50 + "px";
   } else {
    searchBoxHeght.style.height = "auto";
   }
  },
    receiveTask(row) {
      this.$confirm('确定要开始吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        // 开始提交信息
        receiveTask(row.id).then((data) => {
          this.$router.push({
            path: '/detail/deal',
            query: { projectId: row.projectId, taskId: row.id, projectStatus: row.projectStatus, 
            appointNextTime: row.appointNextTime,ifReceive: row.ifReceive },
          });
        });
      });
    },
    getTask(row) {
      this.$router.push({ path: '/detail/deal', query: { projectId: row.projectId, taskId: row.id, 
      projectStatus: row.projectStatus,taskStatus: row.taskStatus,operationLook: true,activeIndex: "1"  } });
    },
    changePage() {
      this.getList();
    },
    restForm() {
      this.listQuery = {
        pageNo: 1,
        pageSize: 10,
        realName: undefined,
        mobile: undefined,
        idCardNo: undefined,
        pledgeType: undefined,
        projectStatus: undefined,
        startTime: undefined,
        endTime: undefined,
      };
      this.getList();
    },
    cellDblclick({row,rowIndex,column,columnIndex,cell},event) {
      let _this = this;
      this.$copyText(event.target.innerText).then(function() {
        _this.$message.info('复制成功');
      });
    }
  },
};
</script>

<style lang="css" scoped>
.filter-container {
  display: flex;
  justify-content: space-between;
}
.pager{
  position: fixed;
  bottom: 0;
  right: 28px;
  background-color: #FAFAFB;
  z-index: 2;
  height: 40px;
  width: calc(100% - 260px);
  }

.right >>> .el-button--primary,.el-button--default {
  padding: 10px 20px;
}

.vxe-table--render-default >>> .el-button--text{
  color: #2b7bfb;
}
.app-container >>> .vxe-table--render-default,.vxe-pager {
  font-family: PingFangSC, Arial, Helvetica, sans-serif;
}  

.left {
  flex: 14;
  display: flex;
  flex-flow: row wrap;
  margin-right: 20px;
}
.left >>> .el-form {
  width: 100%;
}
.left >>> .el-form .el-form-item {
  display: flex;
  flex-flow: row nowrap;
  width: 30%;
  margin-right: 3%;
  float: left;
  margin-bottom: 14px;
}

.left >>> .el-form .el-form-item .el-form-item__label {
  font-weight: 500;
  color: #606266;
  text-align: left;
  /* flex: 1; */
}

.left >>> .el-form .el-form-item .el-form-item__content {
  flex: 1;
  /*超出部分隐藏*/
  text-overflow: ellipsis;
  /* 超出部分显示省略号 */
  white-space: nowrap;
  /*规定段落中的文本不进行换行 */
  width: 100%;
}
.date_item {
  width: 100%;
}
.right {
  flex: 2;
  display: flex;
  flex-flow: row nowrap;
  align-items: flex-end;
  margin-right: 30px;
}
</style>
